package com.seckill.common.error;

/**
 * 业务异常类实现--使用
 */
public class BusinessException extends Exception implements CommonError {

    // 组合，强关联
    private CommonError commonError;

    public BusinessException(CommonError commonError) {
        super();
        this.commonError = commonError;
    }

    public BusinessException(CommonError commonError, String customErrMsg) {
        super();
        this.commonError = commonError;
        this.commonError.setErrorMsg(customErrMsg);
    }

    @Override
    public int getErrorCode() {
        return this.commonError.getErrorCode();
    }

    @Override
    public String getErrorMsg() {
        return this.commonError.getErrorMsg();
    }

    @Override
    public CommonError setErrorMsg(String errorMsg) {
        this.commonError.setErrorMsg(errorMsg);
        return this;
    }
}
